// pages/user/toTeam/toTeam.js
//获取应用实例
const app = getApp();
var that;

Page({

  /**
   * 页面的初始数据
   */
  data: {
      id:-1,
      resultList:{},
      count:1,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    that = this;
    //that.data.id = options.id;
    that.setData({
      id: options.id,
    })
    //id 为playArr的参数
    console.log("[Console log]:onLoad..." + that.data.id)

    wx.request({
      url: app.globalData.URL + '/playArrangement/findByPlayArrId?id=' + that.data.id,
      data: {
        
      },
      header: {
        'content-type': 'application/json' // 默认值
      },
      complete: function (res) {
        //返回场次信息和 对应的剧本内容 key : playArr, playBook
        console.log("[Console log]:RESULT..." + JSON.stringify(res.data));
        that.setData({
          resultList: res.data,
        })
        console.log(that.data.resultList.playArr)
        console.log(that.data.resultList.playBook)
      }

    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  },

  add: function () {
    var sum = that.data.resultList.playBook.mostPeople - that.data.resultList.playArr.subPeople;
    if (that.data.count < sum){
         that.data.count++;
         that.setData({
        count: that.data.count
         })
      }
    console.log(that.data.count)
  },

  sub: function () {
    if (that.data.count > 1) {
      that.data.count--;
      that.setData({
        count: that.data.count
      })
    }
    console.log(that.data.count)
  },
})